/*
#include <stdio.h>
#include<math.h>
int main( )
{
	int i = 0;
	int n = 0;
	scanf("%d",&n);
	int num = pow(10,n);
	for(i=1;i<num;i++)
	{
		printf("%d ",i);
	}
	return 0;
}
int* printNumbers(int n, int* returnSize )
{
	
}
*/
#include <stdio.h>
int main()
{
    int commonyear[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
    int lunaryear[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
    int year,month,day;
    int sum = 0;
    int i = 0;
    scanf("%d %d %d",&year,&month,&day);
    if((year%4==0)&&(year%100!=0)||(year%400)==0)
    {
        for(i=0;i<month-1;i++)
        {
            sum += lunaryear[i];
        }
        sum += day;
        printf("%d",sum);
    }
    else
    {
        for(i=0;i<month-1;i++)
        {
            sum += commonyear[i];
        }
        sum += day;
        printf("%d",sum);
    }
    return 0;
}
